import { SkerRender } from "./SkerRender";
declare const WindowManager: any;
export class InfoRender extends SkerRender {
    showPrintWindow: boolean = false;
    msgWindow: AutoJs.FloatyWindow;
    render(): void {
        importClass('android.view.WindowManager');
        importClass("android.view.Gravity");
        importClass("android.graphics.PixelFormat");
        this.showPrintWindow = true;
        this.msgWindow = floaty.window(`<vertical id="msgLayout" padding="5" margin="0" bg="#000000">
        <text id="msg" text="暂无信息" textColor="#ffffff"/>
    </vertical>`);
        ui.run(() => {
            const parentParent = this.msgWindow.msgLayout.parent.parent.parent;
            let params = parentParent.layoutParams || {};
            if (params.flags == 16777736) {
                params.flags |= WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
            } else if (params.flags == 16777752) {
                params.flags &= ~WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE;
            }
            const windowManager = context.getSystemService(context.WINDOW_SERVICE);
            windowManager.updateViewLayout(parentParent, params);
            this.msgWindow.setPosition(0, 0)
        })
    }
    close() {
        this.showPrintWindow = false;
    }
    open() {
        this.showPrintWindow = true;
    }
    destory() {
        this.showPrintWindow = false;
        this.msgWindow?.close()
    }
    isShow() {
        return this.showPrintWindow;
    }
    update(str: string) {
        ui.run(() => {
            this.msgWindow && this.msgWindow.msg.setText(str)
        })
    }
}